<!--
  ###license-information-start###
  E-PIX - Enterprise Patient Identifier Cross-referencing
  __
  Copyright (C) 2009 - 2017 The MOSAIC Project - Institut fuer Community Medicine der
  							Universitaetsmedizin Greifswald - mosaic-projekt@uni-greifswald.de
  							concept and implementation
  							c. schack, d.langner, l. geidel
  							web client
  							a. blumentritt
  							g. weiher
  							please cite our publications
  							http://dx.doi.org/10.3414/ME14-01-0133
  							http://dx.doi.org/10.1186/s12967-015-0545-6
  __
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU Affero General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  ###license-information-end###
  -->
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:customs = "http://java.sun.com/jsf/composite/customs">
<!-- author: mathiasd -->
<!-- edited by: bialkem -->
<h:body>

	<ui:composition template="/template/ths_templ.xhtml">
	
		<ui:define name="meta_tags">
			<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
			<meta http-equiv="Pragma" content="no-cache" />
			<meta http-equiv="Expires" content="0" />
		</ui:define>
		
		<!--  method is called when page is loaded / without output  -->
		<ui:define name="start">
			<h:outputText value="#{searchBean.onStart()}" />
		</ui:define>
		
	
		<ui:define name="customLogo">
			<a href="index.xhtml"><img src="#{request.contextPath}/img/epix_logo.png" /></a>
		</ui:define>
		
		<ui:define name="header_title">
			<h:outputFormat value="#{msg['general.headertitle']}"/>
		</ui:define>
		
		<ui:define name="title">
			<h:outputFormat value="#{msg['general.title']}" />
		</ui:define>
				
		<ui:define name="info">
				<customs:headerMenu activeIndex="3" />
		</ui:define>
		
		<ui:define name="content">
			<h:form id="main">

				<h:outputText value="#{msg['search.label.usage_info']}" />

				<h:outputText value="#{msg['search.label.parameters']}"
					styleClass="headline" />
				<p:panel>
					<h:panelGrid columns="2" columnClasses="label,input">
						<h:outputText value="#{msg.lastName}:" />
						<p:inputText value="#{searchBean.patientModel.lastName}" />
						<!--*******************************************************************-->
						<h:outputText value="#{msg.firstName}:" />
						<p:inputText value="#{searchBean.patientModel.firstName}" />
						<!--*******************************************************************-->
						<h:outputText value="#{msg.birthDate}#{msg.ddmmyyyy}:" />
						<h:panelGroup>
							<p:inputMask id="birthDate"
								value="#{searchBean.patientModel.birthDate}" mask="99.99.9999">
								<f:convertDateTime pattern="dd.MM.yyyy" />
							</p:inputMask>
							<p:message id="birthDateMessage" for="birthDate"
								showDetail="true" autoUpdate="true" />
						</h:panelGroup>
						<!--*******************************************************************-->
						<h:outputText value="#{msg.mpi}:" />
						<p:inputText value="#{searchBean.patientModel.mpiid.value}" />
						<!--*******************************************************************-->
						<h:outputText value="#{msg.localDomain}:" />
						<p:selectOneMenu id="localDomain"
							value="#{searchBean.patientModel.identifierDomain}"
							style="width: 100% !important">
							<f:selectItem noSelectionOption="true"
								itemLabel="No Domain selected" itemValue="" />
							<f:selectItems value="#{searchBean.formModel.localDomains}"
								var="domain" itemLabel="#{domain.name}"
								itemValue="#{domain.name}" />
							<p:ajax update="identifierDomainInput" listener="#{searchBean.onDomainChanged}"/>
						</p:selectOneMenu>
						<!--*******************************************************************-->
						<h:outputText value="#{msg.localIdentifier}:" />
						<p:inputText id="identifierDomainInput"
							disabled="#{empty searchBean.patientModel.identifierDomain}"
							value="#{searchBean.patientModel.localIdentifier}" />
						<!--*******************************************************************-->
						<h:outputText id="addContactButtonLabel_epmty" value="" />
						<h:panelGroup>
							<div align="right">
							<p:commandButton value="#{msg.searchPerson}"
								action="#{searchBean.searchPerson()}" update=":table"
								style="font-weight: bold;" />
							</div>
							<p:messages id="searchButtonInfo" for="info" showDetail="true"
								autoUpdate="true" severity="info" />
						
						</h:panelGroup>					
					</h:panelGrid>
				</p:panel>
			</h:form>
								
			
			<h:outputText value="#{msg['search.label.results']}" styleClass="headline" />		
			<h:form id="table">								

				<p:dataTable var="entry" value="#{searchBean.entryModel}"
					selectionMode="single" resizableColumns="true"
					scrollable="false" liveScroll="false"
					scrollRows="20" lazy="true" emptyMessage="#{msg['error.noPersonFound']}">

					<p:column headerText="#{msg.mpi}">
						<h:outputText value="#{entry.person.mpiid.value}" />
					</p:column>
					<p:column headerText="#{msg.lastName}">
						<h:outputText value="#{entry.person.lastName}" />
					</p:column>
					<p:column headerText="#{msg.firstName}">
						<h:outputText value="#{entry.person.firstName}" />
					</p:column>
					<p:column headerText="#{msg.gender}"  style="text-align:center">
						<h:outputText value="#{entry.person.gender}" />
					</p:column>
					<p:column headerText="#{msg.birthDate}"  style="text-align:center">							 		
						<p:outputLabel value="#{entry.person.birthDate}">
						</p:outputLabel>
					</p:column>
					<p:column headerText="#{msg.edit}" style="text-align:center">						
							<p:commandButton id="rowEditButton"							
								icon="ui-icon-pencil"
								action="#{searchBean.editButtonListener(entry)}" />
					</p:column>					
				</p:dataTable>
			</h:form>
			
		</ui:define>
		
		<ui:define name="version">	
			<h:outputText value="${display_version}"/>
		</ui:define>
		
	</ui:composition>
</h:body>
</html>
